#include <iostream>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>

void handler(int sig)
{
    while(1)
    {
        std::cout<<"signal:"<<sig<<std::endl;
        sigset_t pending;
        sigpending(&pending);
        for(int i=31;i>=1;i--)
        {
            if(sigismember(&pending,i))
            {
                std::cout<<1;
            }
            else
            {
                std::cout<<0;
            }
        }
        std::cout<<std::endl;
        sleep(1);
    }
}

int main()
{
    struct sigaction act,oact;
    act.sa_flags=0;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask,3);
    sigaddset(&act.sa_mask,4);
    act.sa_handler=handler;

    sigaction(SIGINT,&act,&oact);

    while(1)
    {
        std::cout<<"hello world "<<getpid()<<std::endl;
        sleep(1);
    }

    return 0;
}